package com.pubinfo.passbook.api.controller.rule;

import com.pubinfo.passbook.common.entity.TRuleCity;
import com.pubinfo.passbook.common.model.dto.rule.RuleCityParam;
import com.pubinfo.passbook.common.model.vo.base.JsonResult;
import com.pubinfo.passbook.common.model.vo.base.MyPage;
import com.pubinfo.passbook.common.service.master.TRuleCityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "city/manager")
@Api(tags = "城市管理")
public class TCityController {
  
  @Resource
  private TRuleCityService cityService;
  
  @PostMapping("save")
  @ApiModelProperty("新增城市")
  public JsonResult<Boolean> saveRuleCity(@RequestBody TRuleCity ruleCity) {
    return JsonResult.success(cityService.saveOrUpdate(ruleCity));
  }
  
  @DeleteMapping("remove")
  @ApiModelProperty("删除城市")
  public JsonResult<String> removeRuleCity(String cityId) {
    return cityService.removeRuleCity(cityId);
  }
  
  @PostMapping("select")
  @ApiModelProperty("查询城市")
  public JsonResult<MyPage<TRuleCity>> selectRuleCity(@RequestBody RuleCityParam param) {
    return JsonResult.success(new MyPage(cityService.selectRuleCity(param)));
  }
}
